import roleRepository from '@/repositories/role'

const getRoleAndAuthorization = async (loadCondition) => {
  return await roleRepository.getRoleAndAuthorization(loadCondition)
}

const addRole = async (params) => {
  return await roleRepository.addRole(params)
}

const updateRole = async (params) => {
  return await roleRepository.updateRole(params)
}

const delRole = async (roleId) => {
  return await roleRepository.delRole(roleId)
}

const addRoleAuthorization = async (params) => {
  return await roleRepository.addRoleAuthorization(params)
}

const delRoleAuthorization = async (roleAuthorizationId) => {
  return await roleRepository.delRoleAuthorization(roleAuthorizationId)
}

const getRoleAuthorizationByRoleId = async (roleId) => {
  let roleAuthorizationResult = await roleRepository.getRoleAuthorizationByRoleId(roleId)
  return roleAuthorizationResult.data.roleAuths
}

export default {
  getRoleAndAuthorization: getRoleAndAuthorization,
  addRole: addRole,
  updateRole: updateRole,
  delRole: delRole,
  addRoleAuthorization: addRoleAuthorization,
  delRoleAuthorization: delRoleAuthorization,
  getRoleAuthorizationByRoleId: getRoleAuthorizationByRoleId
}
